// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   LabelValueBean.java

package com.sitech.ibnms.util;

import java.io.Serializable;
import java.util.Comparator;

public class LabelValueBean implements Comparable, Serializable {

	public static final Comparator CASE_INSENSITIVE_ORDER = new Comparator() {

		public int compare(Object o1, Object o2) {
			String label1 = ((LabelValueBean) o1).getLabel();
			String label2 = ((LabelValueBean) o2).getLabel();
			return label1.compareToIgnoreCase(label2);
		}

	};
	private String label;
	private String value;

	public LabelValueBean() {
		label = null;
		value = null;
	}

	public LabelValueBean(String label, String value) {
		this.label = null;
		this.value = null;
		this.label = label;
		this.value = value;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public int compareTo(Object o) {
		String otherLabel = ((LabelValueBean) o).getLabel();
		return getLabel().compareTo(otherLabel);
	}

	public String toString() {
		StringBuffer sb = new StringBuffer("LabelValueBean[");
		sb.append(label);
		sb.append(", ");
		sb.append(value);
		sb.append("]");
		return sb.toString();
	}

	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof LabelValueBean))
			return false;
		LabelValueBean bean = (LabelValueBean) obj;
		int nil = getValue() != null ? 0 : 1;
		nil += bean.getValue() != null ? 0 : 1;
		if (nil == 2)
			return true;
		if (nil == 1)
			return false;
		else
			return getValue().equals(bean.getValue());
	}

	public int hashCode() {
		return getValue() != null ? getValue().hashCode() : 17;
	}

}
